import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n('asset.assetApproval.fields');
const { t: common } = useI18n('common');
const approvalFields = {
  type: t('type'),
  number: t('number'),
  createBy: t('createBy'),
  description: t('description'),
  createTime: t('createTime'),
  status: t('status'),
  operater: t('operater'),
  remark: t('remark'),
  identification: t('identification'),
};
//列表数据
export const columns: BasicColumn[] = [
  {
    title: approvalFields.type,
    align: 'center',
    dataIndex: 'type',
    customRender: ({ text }) => {
      return render.renderDict(text, 'approvalType');
    },
  },
  {
    title: approvalFields.number,
    align: 'center',
    dataIndex: 'billid',
  },
  {
    title: approvalFields.createBy,
    align: 'center',
    dataIndex: 'createBy',
  },
  {
    title: approvalFields.createTime,
    align: 'center',
    dataIndex: 'createTime',
  },
  {
    title: approvalFields.status,
    align: 'center',
    dataIndex: 'status',
    customRender: ({ text }) => {
      return render.renderDict(text, 'documentStatus', true, { '2': 'blue', '3': 'green', '4': 'red' });
    },
  },
  {
    title: approvalFields.operater,
    align: 'center',
    dataIndex: 'updateBy_dictText',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: approvalFields.status,
    field: 'status',
    component: 'JSelectMultiple',
    defaultValue: '2',
    componentProps: {
      dictCode: 'documentStatus',
      showChooseOption: false,
      multiple: true,
    },
  },

  {
    label: approvalFields.createTime,
    field: 'createTime',
    component: 'RangePicker',
    componentProps: {
      // showTime: true,
      // valueFormat: 'YYYY-MM-DD',
    },
  },
  {
    label: approvalFields.operater,
    field: 'updateBy',
    component: 'JSelectUserByDept',
    componentProps: {
      showButton: false,
    },
  },
  {
    label: approvalFields.number,
    field: 'billid',
    component: 'JInput',
    componentProps: {
      type: 'like',
    },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: approvalFields.remark,
    field: 'remark',
    component: 'InputTextArea',
    dynamicRules: () => {
      return [{ required: true }];
    },
  },
  {
    label: approvalFields.identification,
    field: 'identification',
    component: 'RfidSelect',
    dynamicRules: () => {
      return [{ required: true }];
    },
  },

  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
